package ioc.config.condition;

import ioc.bean.People;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * 类中组件统一设置。满足当前条件，这个类中配置的所有 bean 注册才能生效
 */
@Conditional({MyConditionByWindows.class, MyConditionByLinux.class})
@Configuration
public class ConditionConfig {

    @Conditional(MyConditionByWindows.class)
    @Bean("Bill Gates-Windows")
    public People bill() {
        return new People("Bill Gates", 63, "Windows");
    }

    @Conditional(MyConditionByLinux.class)
    @Bean("Linus Benedict Torvalds-Linux")
    public People linus() {
        return new People("Linus Benedict Torvalds", 49, "Linux");
    }
}
